//
//  SISSImportSellerInfoView.m
//  SISSAPP
//
//  Created by 优房网 on 2017/9/6.
//  Copyright © 2017年 优房网. All rights reserved.
//

#import "SISSImportSellerInfoView.h"
#import "SISSSellerInfoModel.h"

@interface SISSImportSellerInfoView ()

/// titleLabel
@property (weak, nonatomic) UILabel *titleLabel;

/// bgView
@property (weak, nonatomic) UIView *bgView;

// 姓名Label
@property (weak, nonatomic) UILabel *nameLabel;
@property (weak, nonatomic) UILabel *nameTitleLabel;
/// 身份证/护照号码Label
@property (weak, nonatomic) UILabel *IDCardNoLabel;
@property (weak, nonatomic) UILabel *IDCardNoTitleLabel;
/// 产权证书类别Label
@property (weak, nonatomic) UILabel *propertyClassLabel;
@property (weak, nonatomic) UILabel *propertyClassTitleLabel;
/// 产权证书编号Label
@property (weak, nonatomic) UILabel *propertyNumberLabel;
@property (weak, nonatomic) UILabel *propertyNumberTitleLabel;
/// 共有权人姓名Label
@property (weak, nonatomic) UILabel *commonPropertyNameLabel;
@property (weak, nonatomic) UILabel *commonPropertyNameTitleLabel;
/// 共有权人身份证号Label
@property (weak, nonatomic) UILabel *commonPropertyIDCardLabel;
@property (weak, nonatomic) UILabel *commonPropertyIDCardTitleLabel;

/// 水印
@property (weak, nonatomic) UIImageView *waterMarkImageView;

@end
@implementation SISSImportSellerInfoView


- (void)setSellerInfoModel:(SISSSellerInfoModel *)sellerInfoModel {
    _sellerInfoModel = sellerInfoModel;
    
    self.nameLabel.text = sellerInfoModel.seller_name;
    self.IDCardNoLabel.text = sellerInfoModel.idNo;
//    self.propertyClassLabel.text = sellerInfoModel.
//    self.commonPropertyNameLabel.text =
//    self.commonPropertyIDCardLabel.text =
}

- (void)setTitle:(NSString *)title {
    _title = title;
    self.titleLabel.text = title;
}

- (void)setIsShowWaterMark:(BOOL)isShowWaterMark {
    _isShowWaterMark = isShowWaterMark;
    
    self.waterMarkImageView.hidden = !isShowWaterMark;
}


#pragma mark - UI
- (void)initUI {
    [super initUI];
    
    UILabel *titleLabel = [[UILabel alloc] init];
    titleLabel.text = @"标题";
    titleLabel.textColor = MAIN_TEXT_COLOR;
    titleLabel.font = [UIFont boldSystemFontOfSize:16];
    [self addSubview:titleLabel];
    self.titleLabel = titleLabel;
    
    UIView *bgView = [[UIView alloc] init];
    bgView.backgroundColor = COLOR(0xF1F1F5);
    bgView.layer.cornerRadius = 5;
    bgView.layer.masksToBounds = YES;
    [self addSubview:bgView];
    self.bgView = bgView;
    
    UILabel *nameTitleLabel = [[UILabel alloc] init];
    nameTitleLabel.text = @"姓名：";
    nameTitleLabel.textColor = COLOR(0x8998A5);
    nameTitleLabel.font = [UIFont systemFontOfSize:16];
    [self.bgView addSubview:nameTitleLabel];
    self.nameTitleLabel = nameTitleLabel;
    
    UILabel *nameLabel = [[UILabel alloc] init];
    nameLabel.text = @" ";
    nameLabel.textColor = MAIN_TEXT_COLOR;
    nameLabel.font = [UIFont boldSystemFontOfSize:16];
    [self.bgView addSubview:nameLabel];
    self.nameLabel = nameLabel;
    
    UILabel *IDCardNoTitleLabel = [[UILabel alloc] init];
    IDCardNoTitleLabel.text = @"身份证号：";
    IDCardNoTitleLabel.textColor = COLOR(0x8998A5);
    IDCardNoTitleLabel.font = [UIFont systemFontOfSize:16];
    [self.bgView addSubview:IDCardNoTitleLabel];
    self.IDCardNoTitleLabel = IDCardNoTitleLabel;
    
    UILabel *IDCardNoLabel = [[UILabel alloc] init];
    IDCardNoLabel.text = @" ";
    IDCardNoLabel.textColor = MAIN_TEXT_COLOR;
    IDCardNoLabel.font = [UIFont boldSystemFontOfSize:16];
    IDCardNoLabel.numberOfLines = 2;
    [self.bgView addSubview:IDCardNoLabel];
    self.IDCardNoLabel = IDCardNoLabel;
    
    UILabel *propertyClassTitleLabel = [[UILabel alloc] init];
    propertyClassTitleLabel.text = @"产权证书类别：";
    propertyClassTitleLabel.textColor = COLOR(0x8998A5);
    propertyClassTitleLabel.font = [UIFont systemFontOfSize:16];
    [self.bgView addSubview:propertyClassTitleLabel];
    self.propertyClassTitleLabel = propertyClassTitleLabel;
    
    UILabel *propertyClassLabel = [[UILabel alloc] init];
    propertyClassLabel.text = @" ";
    propertyClassLabel.textColor = MAIN_TEXT_COLOR;
    propertyClassLabel.font = [UIFont boldSystemFontOfSize:16];
    [self.bgView addSubview:propertyClassLabel];
    self.propertyClassLabel = propertyClassLabel;
    
    UILabel *propertyNumberTitleLabel = [[UILabel alloc] init];
    propertyNumberTitleLabel.text = @"产权证书编号：";
    propertyNumberTitleLabel.textColor = COLOR(0x8998A5);
    propertyNumberTitleLabel.font = [UIFont systemFontOfSize:16];
    [self.bgView addSubview:propertyNumberTitleLabel];
    self.propertyNumberTitleLabel = propertyNumberTitleLabel;
    
    UILabel *propertyNumberLabel = [[UILabel alloc] init];
    propertyNumberLabel.text = @" ";
    propertyNumberLabel.textColor = MAIN_TEXT_COLOR;
    propertyNumberLabel.font = [UIFont boldSystemFontOfSize:16];
    propertyNumberLabel.numberOfLines = 0;
    [self.bgView addSubview:propertyNumberLabel];
    self.propertyNumberLabel = propertyNumberLabel;
    
    UILabel *commonPropertyNameTitleLabel = [[UILabel alloc] init];
    commonPropertyNameTitleLabel.text = @"共有权人姓名：";
    commonPropertyNameTitleLabel.textColor = COLOR(0x8998A5);
    commonPropertyNameTitleLabel.font = [UIFont systemFontOfSize:16];
    [self.bgView addSubview:commonPropertyNameTitleLabel];
    self.commonPropertyNameTitleLabel = commonPropertyNameTitleLabel;
    
    UILabel *commonPropertyNameLabel = [[UILabel alloc] init];
    commonPropertyNameLabel.text = @" ";
    commonPropertyNameLabel.textColor = MAIN_TEXT_COLOR;
    commonPropertyNameLabel.font = [UIFont boldSystemFontOfSize:16];
    [self.bgView addSubview:commonPropertyNameLabel];
    self.commonPropertyNameLabel = commonPropertyNameLabel;
    
    UILabel *commonPropertyIDCardTitleLabel = [[UILabel alloc] init];
    commonPropertyIDCardTitleLabel.text = @"共有权人身份证号：";
    commonPropertyIDCardTitleLabel.textColor = COLOR(0x8998A5);
    commonPropertyIDCardTitleLabel.font = [UIFont systemFontOfSize:16];
    [self.bgView addSubview:commonPropertyIDCardTitleLabel];
    self.commonPropertyIDCardTitleLabel = commonPropertyIDCardTitleLabel;
    
    UILabel *commonPropertyIDCardLabel = [[UILabel alloc] init];
    commonPropertyIDCardLabel.text = @" ";
    commonPropertyIDCardLabel.textColor = MAIN_TEXT_COLOR;
    commonPropertyIDCardLabel.font = [UIFont boldSystemFontOfSize:16];
    [self.bgView addSubview:commonPropertyIDCardLabel];
    self.commonPropertyIDCardLabel = commonPropertyIDCardLabel;
    
    UIImageView *waterMarkImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"dataWaterMark"]];
    [waterMarkImageView sizeToFit];
    waterMarkImageView.hidden = YES;
    [self.bgView addSubview:waterMarkImageView];
    
    self.waterMarkImageView = waterMarkImageView;
}

#pragma mark - 布局
- (void)initConstraint {
    [super initConstraint];
    
    WeakSelf
    CGFloat margin = 8.0;
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf).offset(margin);
        make.top.equalTo(weakSelf).offset(margin);
    }];
    
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.titleLabel);
        make.top.equalTo(weakSelf.titleLabel.mas_bottom).offset(margin);
        make.bottom.right.equalTo(weakSelf).offset(-margin);
    }];
    [self.nameTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.bgView).offset(margin);
        make.top.equalTo(weakSelf.bgView).offset(2 * margin);
    }];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.nameTitleLabel.mas_right);
        make.top.equalTo(weakSelf.nameTitleLabel);
    }];
    
    [self.IDCardNoTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.nameTitleLabel);
        make.top.equalTo(weakSelf.nameTitleLabel.mas_bottom).offset(2 * margin);
    }];
    [self.IDCardNoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.IDCardNoTitleLabel.mas_right);
        make.centerY.equalTo(weakSelf.IDCardNoTitleLabel);
    }];
    
    [self.propertyClassTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.IDCardNoTitleLabel);
        make.top.equalTo(weakSelf.IDCardNoLabel.mas_bottom).offset(2 * margin);
    }];
    [self.propertyClassLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.propertyClassTitleLabel.mas_right);
        make.top.equalTo(weakSelf.propertyClassTitleLabel);
        make.right.equalTo(weakSelf.bgView);
    }];
    
    [self.propertyNumberTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.propertyClassTitleLabel);
        make.top.equalTo(weakSelf.propertyClassTitleLabel.mas_bottom).offset(2 * margin);
    }];
    [self.propertyNumberLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.propertyNumberTitleLabel.mas_right);
        make.top.equalTo(weakSelf.propertyNumberTitleLabel);
//        make.right.equalTo(weakSelf.bgView).offset(-margin);
    }];
    
    [self.commonPropertyNameTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.propertyNumberTitleLabel);
        make.top.equalTo(weakSelf.propertyNumberLabel.mas_bottom).offset(2 * margin);
    }];
    [self.commonPropertyNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.commonPropertyNameTitleLabel.mas_right);
        make.centerY.equalTo(weakSelf.commonPropertyNameTitleLabel);
    }];
    
    [self.commonPropertyIDCardTitleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.commonPropertyNameTitleLabel);
        make.top.equalTo(weakSelf.commonPropertyNameTitleLabel.mas_bottom).offset(2 * margin);
    }];
    [self.commonPropertyIDCardLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(weakSelf.commonPropertyIDCardTitleLabel.mas_right);
        make.centerY.equalTo(weakSelf.commonPropertyIDCardTitleLabel);
        make.bottom.equalTo(weakSelf.bgView).offset(-margin);
    }];
    
    [self.waterMarkImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.center.equalTo(weakSelf.bgView);
    }];
}


@end

